package com.example.ncpapplication.utils;

import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

public class OkHttp {

    private static OkHttpClient client;

    static { client = new OkHttpClient(); }

    public static void requestData(String date, Callback callback) {
        FormBody.Builder builder = new FormBody.Builder();
        builder.add("key", "f089047b51a868e099b4bb945993540a");
        builder.add("date", date);
        RequestBody body = builder.build();
        Request request = new Request.Builder()
                .url("http://api.tianapi.com/txapi/ncovcity/index")
                .post(body)
                .build();
        client.newCall(request).enqueue(callback);
    }

}
